// 驾校相关的API数据

// 驾校列表数据
export const getSchoolList = (page = 1, pageSize = 10) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      const allData = [
        {
          id: 1,
          name: '阳光驾校',
          address: '北京市朝阳区建国路88号',
          image: '',
          tags: ['C1', 'C2', '包过班']
        },
        {
          id: 2,
          name: '蓝天驾校',
          address: '北京市海淀区中关村大街1号',
          image: '',
          tags: ['C1', 'C2', 'VIP班']
        },
        {
          id: 3,
          name: '星辰驾校',
          address: '北京市丰台区南三环西路15号',
          image: '',
          tags: ['C1', '经济班']
        },
        {
          id: 4,
          name: '未来驾校',
          address: '北京市西城区西单北大街120号',
          image: '',
          tags: ['C1', 'C2', '速成班']
        },
        {
          id: 5,
          name: '梦想驾校',
          address: '北京市东城区王府井大街200号',
          image: '',
          tags: ['C1', 'C2', '周末班']
        },
        {
          id: 6,
          name: '卓越驾校',
          address: '北京市昌平区回龙观东大街1号',
          image: '',
          tags: ['C1', 'C2', '精英班']
        },
        {
          id: 7,
          name: '华信驾校',
          address: '北京市顺义区机场东路88号',
          image: '',
          tags: ['C1', 'C2', '速成班']
        },
        {
          id: 8,
          name: '东方驾校',
          address: '北京市通州区新华大街200号',
          image: '',
          tags: ['C1', '经济班']
        },
        {
          id: 9,
          name: '北方驾校',
          address: '北京市大兴区黄村西大街15号',
          image: '',
          tags: ['C1', 'C2', 'VIP班']
        },
        {
          id: 10,
          name: '南方驾校',
          address: '北京市房山区良乡大街100号',
          image: '',
          tags: ['C1', 'C2', '包过班']
        },
        {
          id: 11,
          name: '西部驾校',
          address: '北京市门头沟区新桥大街50号',
          image: '',
          tags: ['C1', '经济班']
        },
        {
          id: 12,
          name: '东部驾校',
          address: '北京市平谷区府前大街30号',
          image: '',
          tags: ['C1', 'C2', '速成班']
        }
      ];

      // 计算分页
      const startIndex = (page - 1) * pageSize;
      const endIndex = startIndex + pageSize;
      const pageData = allData.slice(startIndex, endIndex);
      const total = allData.length;
      const totalPages = Math.ceil(total / pageSize);

      resolve({
        code: 200,
        data: pageData,
        pagination: {
          page,
          pageSize,
          total,
          totalPages,
          hasNext: page < totalPages,
          hasPrev: page > 1
        },
        message: '获取成功'
      });
    }, 500);
  });
};

// 驾校详情数据
export const getSchoolDetail = (id = 1) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      const schoolId = parseInt(id) || 1;
      const schoolList = [
        {
          id: 1,
          name: '阳光驾校',
          address: '北京市朝阳区建国路88号',
          price: '3980',
          image: 'https://picsum.photos/400/200?random=201',
          tags: ['C1', 'C2', '包过班'],
          intro: '阳光驾校成立于2010年，拥有专业的教练团队和先进的训练场地。我们致力于为学员提供优质的学车服务，通过率高达95%以上。',
          coaches: [
            { name: '王教练', intro: '耐心细致', img: 'https://picsum.photos/800/400?random=201' },
            { name: '李教练', intro: '经验丰富', img: 'https://picsum.photos/800/400?random=202' },
            { name: '张教练', intro: '幽默风趣', img: 'https://picsum.photos/800/400?random=203' },
            { name: '赵教练', intro: '认真负责', img: 'https://picsum.photos/800/400?random=204' }
          ],
          classTypes: [
            {
              id: 1,
              name: 'C1 手动挡',
              description: '适合大部分学员，学车灵活，考试通过率高。',
              image: 'https://picsum.photos/800/400?random=301',
              features: ['手动挡操作', '考试通过率高', '适合初学者']
            },
            {
              id: 2,
              name: 'C2 自动挡',
              description: '操作简单，适合女性及喜欢自动挡的学员。',
              image: 'https://picsum.photos/800/400?random=303',
              features: ['自动挡操作', '操作简单', '适合女性学员']
            }
          ]
        }
      ];

      const school = schoolList.find(item => item.id === schoolId);
      
      if (school) {
        resolve({
          code: 200,
          data: school,
          message: '获取成功'
        });
      } else {
        // 如果找不到对应ID的驾校，返回ID为1的驾校
        const defaultSchool = schoolList.find(item => item.id === 1);
        resolve({
          code: 200,
          data: defaultSchool,
          message: '获取成功'
        });
      }
    }, 500);
  });
};



// 获取班型列表
export const getClassList = (page = 1, pageSize = 10) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      const allClassTypes = [
        {
          id: 1,
          name: 'C1 手动挡',
          description: '适合大部分学员，学车灵活，考试通过率高。',
          image: 'https://picsum.photos/800/400?random=301',
          price: '3980',
          duration: '3个月',
          features: ['手动挡操作', '考试通过率高', '适合初学者']
        },
        {
          id: 2,
          name: 'C2 自动挡',
          description: '操作简单，适合女性及喜欢自动挡的学员。',
          image: 'https://picsum.photos/800/400?random=302',
          price: '4280',
          duration: '2.5个月',
          features: ['自动挡操作', '操作简单', '适合女性学员']
        },
        {
          id: 3,
          name: 'VIP班',
          description: '一对一教学，专属教练，快速拿证。',
          image: 'https://picsum.photos/800/400?random=303',
          price: '5980',
          duration: '2个月',
          features: ['一对一教学', '专属教练', '快速拿证']
        },
        {
          id: 4,
          name: '速成班',
          description: '集中训练，快速掌握驾驶技能。',
          image: 'https://picsum.photos/800/400?random=304',
          price: '4580',
          duration: '1.5个月',
          features: ['集中训练', '快速掌握', '高效学习']
        },
        {
          id: 5,
          name: '经济班',
          description: '性价比高，适合预算有限的学员。',
          image: 'https://picsum.photos/800/400?random=305',
          price: '2980',
          duration: '4个月',
          features: ['性价比高', '基础教学', '适合预算有限']
        },
        {
          id: 6,
          name: '包过班',
          description: '考试不过免费重学，保障学员权益。',
          image: 'https://picsum.photos/800/400?random=306',
          price: '6980',
          duration: '3个月',
          features: ['包过保障', '免费重学', '权益保障']
        },
        {
          id: 7,
          name: '夜班班',
          description: '适合白天工作繁忙的学员，晚上学车。',
          image: 'https://picsum.photos/800/400?random=307',
          price: '5280',
          duration: '3个月',
          features: ['夜班教学', '时间灵活', '适合上班族']
        },
        {
          id: 8,
          name: '周末班',
          description: '只在周末上课，适合工作日忙碌的学员。',
          image: 'https://picsum.photos/800/400?random=308',
          price: '4880',
          duration: '4个月',
          features: ['周末教学', '时间自由', '不影响工作']
        },
        {
          id: 9,
          name: '一对一班',
          description: '专属教练一对一教学，学习效率最高。',
          image: 'https://picsum.photos/800/400?random=309',
          price: '7980',
          duration: '2个月',
          features: ['一对一教学', '专属教练', '高效学习']
        },
        {
          id: 10,
          name: '团体班',
          description: '多人一起学习，价格优惠，氛围活跃。',
          image: 'https://picsum.photos/800/400?random=310',
          price: '3580',
          duration: '3.5个月',
          features: ['团体教学', '价格优惠', '氛围活跃']
        }
      ];

      // 计算分页
      const startIndex = (page - 1) * pageSize;
      const endIndex = startIndex + pageSize;
      const pageData = allClassTypes.slice(startIndex, endIndex);
      const total = allClassTypes.length;
      const totalPages = Math.ceil(total / pageSize);

      resolve({
        code: 200,
        data: pageData,
        pagination: {
          page,
          pageSize,
          total,
          totalPages,
          hasNext: page < totalPages,
          hasPrev: page > 1
        },
        message: '获取成功'
      });
    }, 500);
  });
};


// 报名驾校
export const applySchool = (schoolId, schoolName) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: 200,
        data: {
          schoolId,
          schoolName,
          applyTime: new Date().toISOString()
        },
        message: '报名成功'
      });
    }, 1000);
  });
}; 